﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LL.Data;
using LL.Common;


namespace LL.Business
{
    /// <summary>
    /// 业务会话
    /// </summary>
    /// <remarks>管理DAO的数据连接和事务</remarks>
    public class BusinessSession : ITransaction
    {
        public IDbSession DbSession { get; set; }

        public BusinessSession()
        {

        }

        public void BeginTranscation()
        {
            DbSession.BeginTranscation();
        }

        public void Commit()
        {
            DbSession.Commit();
        }

        public void Rollback()
        {
            DbSession.Rollback();
        }

        public void Dispose()
        {
            DbSession.Dispose();
        }

        public TBo Get<TBo>()
            where TBo : ServiceBase, new()
        {
            return new TBo()
            {
                DbSession = DbSession,
            };
        }

    }
}
